<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="author" content="lijinbo" />
    <title>6-01侧边广告跟随</title>
  </head>
  <style>
    #ad {
      width: 100px;
      height: 200px;
      top: 200px;
      background-color: rgb(162, 206, 61);
      position: absolute;
    }
  </style>

  <body>
    <div id="ad"></div>
    <div style="height: 9000px"></div>
    <script type="module">
      import { startAnimation } from '/utils/module/McAnimation.js'
      var ad = document.getElementById('ad')
      var adTop = ad.offsetTop
      window.onscroll = function () {
        var docScrollTop = document.documentElement.scrollTop || document.body.scrollTop
        startAnimation(ad, { top: docScrollTop + adTop })
      }
    </script>
  </body>
</html>
